package com.addzero.web.ui.hooks.tree.node_state

import com.addzero.web.ui.hooks.tree.TreeNode
import com.addzero.web.ui.hooks.tree.TreeSelectViewModel

// 叶子节点状态
class LeafNodeState : NodeState {
    override fun toggleSelection(node: TreeNode<*>, viewModel: TreeSelectViewModel<*>) {
        // 直接修改选中状态，而不是调用toggleSelection
        val currentSelectedNodes = viewModel._selectedNodes.value
        viewModel._selectedNodes.value = if (currentSelectedNodes.contains(node.id)) {
            currentSelectedNodes - node.id
        } else {
            currentSelectedNodes + node.id
        }
    }

    override fun toggleExpand(node: TreeNode<*>, viewModel: TreeSelectViewModel<*>) {
        // 叶子节点不支持展开/折叠操作
    }
}

